package gui;

import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.RowFilter;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.JScrollPane;
import net.miginfocom.swing.MigLayout;
import java.awt.GridLayout;
import org.jdesktop.swingx.JXTreeTable;

import sys.Video;
import sys.Video.Status;
import sys.VideoTableModel;
import sys.Videos;

import java.awt.FlowLayout;
import java.awt.BorderLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Random;

import javax.swing.table.DefaultTableModel;
import javax.swing.border.TitledBorder;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;

public class JPanelMainContent extends JPanel implements KeyListener {
	
	static VideoList videoList;
	
	/**
	 * Create the panel.
	 */
	public JPanelMainContent() {
		setBorder(null);
		
		setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setViewportBorder(null);
		add(scrollPane);
		
		videoList = new VideoList();
		scrollPane.setViewportView(videoList);		
	}
	
	public void setVideoFilter(String filter) {
		videoList.setRowFilter(RowFilter.regexFilter("(?i)" + filter));
		System.out.println(filter);
	}

	@Override
	public void keyPressed(KeyEvent e) {
	}

	@Override
	public void keyReleased(KeyEvent e) {
		if(e.getSource().getClass().getName().contains("JTextField")) {
			this.setVideoFilter(((JTextField)e.getSource()).getText());
		}
	}

	@Override
	public void keyTyped(KeyEvent e) {
	}

//	public static VideoTable getVideoTable() {
//		return videoTable;
//	}
	
	public static VideoList getVideoList() {
		return videoList;
	}
	
}
